package com.sphd.emanu.activity.itemdetail;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.widget.FrameLayout;

import com.sphd.emanu.R;
import com.sphd.emanu.config.Constant;
import com.sphd.emanu.fragment.details.adetailitem.ADetailItemFragment;
import com.sphd.emanu.fragment.details.bdetailitem.BDetailItemFragment;
import com.sphd.emanu.fragment.details.cdetailitem.CDetailItemFragment;
import com.sphd.emanu.fragment.details.ddetailitem.DDetailItemFragment;
import com.sphd.emanu.fragment.details.edetailitem.EDetailItemFragment;
import com.sphd.emanu.fragment.details.fdetailitem.FDetailItemFragment;
import com.sphd.emanu.fragment.details.gdetailitem.GDetailItemFragment;
import com.sphd.emanu.fragment.details.hdetailitem.HDetailItemFragment;
import com.sphd.emanu.fragment.details.idetailitem.IDetailItemFragment;
import com.sphd.emanu.mvp.MVPBaseActivity;
import com.sphd.emanu.pojo.bank.AccountDetailsBean;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 银行卡明细···
 *
 * @Author Hu
 * @Time 2017/7/24 -- 15:09.
 * @Email 87683202@qq.com
 */
public class ItemDetailActivity extends MVPBaseActivity<ItemDetailContract.View, ItemDetailPresenter> implements ItemDetailContract.View {
    Intent intent;
    Bundle bundle;
    AccountDetailsBean accountDetailsBean;
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.financial_detail_fragment)
    FrameLayout financialDetailFragment;
    ADetailItemFragment detailItemFragmentA;
    BDetailItemFragment detailItemFragmentB;
    CDetailItemFragment detailItemFragmentC;
    DDetailItemFragment detailItemFragmentD;
    EDetailItemFragment detailItemFragmentE;
    FDetailItemFragment detailItemFragmentF;

    GDetailItemFragment detailItemFragmentG;
    HDetailItemFragment detailItemFragmentH;
    IDetailItemFragment detailItemFragmentI;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_item_detail);
        ButterKnife.bind(this);
        initView();

    }

    private void initView() {
        setTitleBar(toolbar, "单条明细");
        intent = getIntent();
        bundle = intent.getExtras();
        accountDetailsBean = (AccountDetailsBean) bundle.getSerializable(Constant.ACCOUNT_DETAILS_BEAN);

        initFragment();
        changeFragment(R.id.financial_detail_fragment, changeFagment(accountDetailsBean),
                accountDetailsBean.getMethod());
    }

    private void initFragment() {
        detailItemFragmentA = new ADetailItemFragment();
        detailItemFragmentB = new BDetailItemFragment();
        detailItemFragmentC = new CDetailItemFragment();
        detailItemFragmentD = new DDetailItemFragment();
        detailItemFragmentE = new EDetailItemFragment();
        detailItemFragmentF = new FDetailItemFragment();
        detailItemFragmentG = new GDetailItemFragment();
        detailItemFragmentH = new HDetailItemFragment();
        detailItemFragmentI = new IDetailItemFragment();
    }

    private Fragment changeFagment(AccountDetailsBean accountDetailsBean) {


        //method 1-现金,2-现金支票,3-转帐支票,4-承兑汇票,5-银行转帐，6-存现金，7-取现金，8-其他内部转账
        switch (accountDetailsBean.getMethod()) {
            case "1":
                if (accountDetailsBean.getPersonnelReimburse() == null) {
                    detailItemFragmentA.setArguments(bundle);
                    return detailItemFragmentA;
                } else {
                    detailItemFragmentI.setArguments(bundle);
                    return detailItemFragmentI;
                }
            case "2":
                detailItemFragmentB.setArguments(bundle);
                return detailItemFragmentB;
            case "3":
                detailItemFragmentC.setArguments(bundle);
                return detailItemFragmentC;
            case "4":
                detailItemFragmentD.setArguments(bundle);
                return detailItemFragmentD;
            case "5":
                if (accountDetailsBean.getPersonnelReimburse() == null) {
                    detailItemFragmentE.setArguments(bundle);
                    return detailItemFragmentE;
                } else {
//                    LookResult.showShortToast(context,"这个玩意儿是报销");
                    detailItemFragmentI.setArguments(bundle);
                    return detailItemFragmentI;
                }
            case "6":
                detailItemFragmentF.setArguments(bundle);
                return detailItemFragmentF;
            case "7":
                detailItemFragmentG.setArguments(bundle);
                return detailItemFragmentG;
            case "8":
                detailItemFragmentH.setArguments(bundle);
                return detailItemFragmentH;
        }
        return detailItemFragmentA;
    }

}
